package com.itheima.wms.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.wms.mapper.CarrierMapper;
import com.itheima.wms.pojo.CarrierPageDto;
import com.itheima.wms.pojo.CarrierVo;
import com.itheima.wms.service.CarrierService;
import com.itheima.wms.utils.PageBean;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@RequiredArgsConstructor
@Service
public class CarrierServiceImpl implements CarrierService {

    private final CarrierMapper carrierMapper;

    @Override
    public PageBean carrierPage(CarrierPageDto carrierPageDto) {
        Integer current = carrierPageDto.getCurrent();
        Integer size = carrierPageDto.getSize();
        PageHelper.startPage(current, size);
        Page<CarrierVo> carrierVos = carrierMapper.carrierPage(carrierPageDto);
        long total = carrierVos.getTotal();
        int pageSize = carrierVos.getPageSize();
        PageBean<CarrierVo> pageBean = new PageBean<CarrierVo>(carrierVos, total, pageSize);
        return pageBean;
    }
}
